package main

import (
	"bufio"
	"fmt"
	"os"
)

func main(){
	var(
		fileName = "./1.txt"
		file *os.File
		err error
	)
	md5SumList := []string{
		"6a09965fb1ad7f14539e569c264b15aa",
		"6a09965fb1ad7f14539e569c264b15ab",
		"6a09965fb1ad7f14539e569c264b15ac",
		"6a09965fb1ad7f14539e569c264b15ad",
		"6a09965fb1ad7f14539e569c264b15ae",
		"6a09965fb1ad7f14539e569c264b15af",
		"6a09965fb1ad7f14539e569c264b15ag",
		"6a09965fb1ad7f14539e569c264b15ah",
		"6a09965fb1ad7f14539e569c264b15ai",
		"6a09965fb1ad7f14539e569c264b15aj",
	}
	file, err = os.OpenFile(fileName, os.O_CREATE|os.O_RDWR, 0666)
	if err != nil{
		fmt.Println("Open file err =", err)
		return
	}
	defer file.Close()
	writer := bufio.NewWriterSize(file, 1024)
	//写入文件
	for i:=0; i< 10000000; i++ {
		content := md5SumList[0] + " " + "1391234567" + " " + "10.23" + "\n"
 		_, err := writer.Write([]byte(content))
		if err != nil{
			return
		}
	}
	writer.Flush()    // 如果程序退出时缓存的数据不够1024，不加这个数据会丢失,即使调用了close()方法
	fmt.Println("done")
}
